$(document).ready(
	function() {
		// TODO: Change to nice popup and add errors to messages table
		$('#language_save_button').bind('click', function() {
			oSaveParams = {
				iLangId : oLang.iLangId,
				sLangText : $('#lang_text').val(),
				sLangAccr : $('#lang_accr').val(),
				sLangActive : (($('#lang_active').attr('checked') === true) ? 'Y' : 'N')
			};
			
			
			if (val_is_empty(oSaveParams.sLangText) === true) {
				alert('No language name given');
				return;
			}

			if (val_is_empty(oSaveParams.sLangAccr) === true) {
				alert('No language acronym given');
				return;
			}
			
			
			$.post('/admin/languages_conf_ajax/save_language', oSaveParams, function(data) {
				if (data.sUpdated) {
					if (oSaveParams.iLangId === 0) {
						$.prompt('<?php echo addslashes($aMessages['admin_language_created']); ?>');
					} else {
						$.prompt('<?php echo addslashes($aMessages['admin_language_updated']); ?>');
					}
				}
			}, 'json');
			
		});
	}
);